﻿using System;
using System.Collections.Generic;
using System.Windows.Media;

namespace Asteroids.Game
{
    public class Projectile : EntityBase
    {
        public int Counter { get; set; }
        public int Life { get; set; }
        public Projectile(Coordinate loc, double direction, double speed) : base()
        {
            Counter = 0;
            Life = 0;
            Dead = false;
            Location = (new Coordinate(loc.X, loc.Y)) + (Coordinate) (Velocity = new PolarCoordinate(direction, speed));

            Brush = Brushes.LimeGreen;
        }

        public override void Update(UpdateEventArgs e)
        {
            Location += (Coordinate) Velocity;

            Counter++;

            if (Counter >= 10)
            {
                OnDeath();
            }
        }

        public override void Collide(CollideEventArgs e)
        {
            OnDeath();
            base.Collide(e);
        }

        protected virtual void OnDeath()
        {
            Dead = true;
        }
    }
}
